***************************************************************************************
*		Reproduction do-file for: 											 		  *
*			Nils D. Steiner 														  * 
* 			The shifting issue content of left-right identification:		 		  *
*			Cohort differences in Western Europe								      *
* 			West European Politics							 				   		  *
***************************************************************************************

***** Instructions: To reproduce all results reported in the article and its appendix:
	// 1. Download a cumulated version of the dataset from the European Social Survey (ESS) including data from rounds 1 to 9  
	// 	  See: https://ess-search.nsd.no/CDW/RoundCountry
	// 2. Run the do-file below on this dataset 
	
	
**# Bookmark #1
********************************************************************************
******************* Settings and preparations **********************************
********************************************************************************
	clear all

/*
*** install ados and graph schemes, if necessary:
	ssc install fre
	ssc install estout, replace
	ssc install coefplot, replace
	ssc install blindschemes, replace
*/

*** settings
	version 17.0
	set more off, permanently
	
*** graph settings
	set scheme plottig
	graph set window fontface "Times New Roman"

***** open ESS dataset
	use "C:\Users\NilsS\OneDrive\Left-right associations\Data\ESS1-9e01_1.dta"
	* use "C:\Users\steinern\OneDrive\Left-right associations\Data\ESS1-9e01_1.dta"
	
	
	
**# Bookmark #2
********************************************************************************
************************* Processing and recoding ******************************
********************************************************************************

****** Reduce dataset
* keep all Western European countries constantly included in ESS rounds 1 to 9
	keep if cntry=="BE" | cntry=="CH" | cntry=="DE" | cntry=="ES" | cntry=="FI" | cntry=="FR" | cntry=="GB" ///
		  | cntry=="IE" | cntry=="NL" | cntry=="NO" | cntry=="PT" | cntry=="SE" 

* keep necessary variables
	keep cntry-pweight ///
		 lrscale gincdif imsmetn imdfetn impcntr imueclt imbgeco imwbcnt freehms impenv ///
		 yrbrn gndr edulvla ///
		 vote prtvt*be prtvt*ch prtv*de2 prtvt*es prtvt*fi prtvt*fr prtvt*gb prtvt*ie prtvt*nl prtvt*no prtvt*pt prtvt*se
		 
		 
******* Recode 
* generate macro-level id variables
	egen cntry_id=group(cntry)
	egen cntry_wave_id=group(cntry essround)

* year of ESS round
	recode essround (1=2002) (2=2004) (3=2006) (4=2008) (5=2010) (6=2012) (7=2014) (8=2016) (9=2018), gen(year)

* left-right scale -> coded from 0 to 1 
	gen leftright=-lrscale+10

	* don't know dummy for left-right position
	recode lrscale (0/10=0) (.b=1), gen(lrscale_dontknow)

* issue items
	* redistribution
	* The government should take measures to reduce differences in income levels
	fre gincdif
	recode gincdif (5=0 "disgagree strongly") (4=1) (3=2) (2=3) (1=4 "agree strongly"), gen(redistribution)

	* homosexuality
	* Gay men and lesbians should be free to live their own life as they wish
	fre freehms
	recode freehms (5=0 "disgagree strongly") (4=1) (3=2) (2=3) (1=4 "agree strongly"), gen(homosexuals)
	
	* environment 
	* Important to care for nature and environment
	fre impenv
	recode impenv (6=0 "not like me at all") (5=1) (4=2) (3=3) (2=4) (1=5 "very much like me"), gen(environment)	
	
	* immigration
	* Allow many/few immigrants from poorer countries outside Europe
	recode impcntr (4=0 "allow none") (3=1) (2=2) (1=3 "allow many to come"), gen(immigration)

		* factor for immigration attitudes 
		sum imsmetn imdfetn impcntr imueclt imbgeco imwbcnt
		factor imsmetn imdfetn impcntr imueclt imbgeco imwbcnt, pcf
		predict immigration_fact
		replace immigration_fact=-immigration_fact
		
		* correlation between item used and factor score
		pwcorr immigration immigration_fact
	
	* standardize issue position -> range from 0 to 1
	gen redistribution_std=redistribution/4
	gen homosexuals_std=homosexuals/4
	gen environment_std=environment/5
	gen immigration_std=immigration/3
	sum immigration_fact
	gen immigration_fact_std=(immigration_fact-r(min))/(r(max)-r(min))

	* label issue variables     
	label variable redistribution_std "redistribution"
	label variable homosexuals_std "homosexuals"
	label variable immigration_std "immigration"
	label variable environment_std "environment"
	label variable immigration_fact_std "immigration"
	
	* cohorts
	gen cohort=0 if yrbrn<=1945
	replace cohort=1 if yrbrn>=1946 & yrbrn<=1964
	replace cohort=2 if yrbrn>=1965 & yrbrn<=1979
	replace cohort=3 if yrbrn>=1980 & yrbrn<=.

	label define cohorts 0 "interwar cohort" 1 "baby boomers" 2 "generation X" 3 "millennials"
	label values cohort cohorts

	* cohorts alternative (robustness) -> 10-year intervals
	gen cohort_alt=0 if yrbrn<=1939
	replace cohort_alt=1 if yrbrn>=1940 & yrbrn<=1949
	replace cohort_alt=2 if yrbrn>=1950 & yrbrn<=1959
	replace cohort_alt=3 if yrbrn>=1960 & yrbrn<=1969
	replace cohort_alt=4 if yrbrn>=1970 & yrbrn<=1979
	replace cohort_alt=5 if yrbrn>=1980 & yrbrn<=1989
	replace cohort_alt=6 if yrbrn>=1990 & yrbrn<=.

	label define cohort_alt 0 "until 1939" 1 "1940s" 2 "1950s" 3 "1960s" 4 "1970s" 5 "1980s" 6 "1990 onwards"
	label values cohort_alt cohort_alt

	* cohorts alternative (robustness) -> 5-year intervals
	gen cohort_alt2=0 if yrbrn<=1924
	replace cohort_alt2=1 if yrbrn>=1925 & yrbrn<=1929
	replace cohort_alt2=2 if yrbrn>=1930 & yrbrn<=1934
	replace cohort_alt2=3 if yrbrn>=1935 & yrbrn<=1939
	replace cohort_alt2=4 if yrbrn>=1940 & yrbrn<=1944
	replace cohort_alt2=5 if yrbrn>=1945 & yrbrn<=1949
	replace cohort_alt2=6 if yrbrn>=1950 & yrbrn<=1954
	replace cohort_alt2=7 if yrbrn>=1955 & yrbrn<=1959
	replace cohort_alt2=8 if yrbrn>=1960 & yrbrn<=1964
	replace cohort_alt2=9 if yrbrn>=1965 & yrbrn<=1969
	replace cohort_alt2=10 if yrbrn>=1970 & yrbrn<=1974
	replace cohort_alt2=11 if yrbrn>=1975 & yrbrn<=1979
	replace cohort_alt2=12 if yrbrn>=1980 & yrbrn<=1984
	replace cohort_alt2=13 if yrbrn>=1985 & yrbrn<=1989
	replace cohort_alt2=14 if yrbrn>=1990 & yrbrn<=1994
	replace cohort_alt2=15 if yrbrn>=1995 & yrbrn<=.
* age
	gen age=year-yrbrn

* age groups
	gen age_group=0 if age<=35
	replace age_group=1 if age>=36 & age<=59
	replace age_group=2 if age>=60

	label define age_group 0 "up to 35" 1 "36 to 59" 2 "60 and older"
	label values age_group age_group

* education
	recode edulvla (1=1 "education: below lower secondary") (2=2 "education: lower secondary") (3 4=3 "education: upper secondary") (5=4 "education: tertiary") (55=.d "other"), gen(education)

	
******* Recode voting decision of respondents
	gen voted = .	
	
	label define voted ///
		0  "Abstention" ///
		1  "Communist/Socialist" ///
		2  "Social democracy" ///
		3  "Green" ///
		4  "Liberal" ///
		5  "Conservative/Christian democracy" ///
		6  "Radical Right" ///
		7  "Agrarian" ///
		8  "Special issue" ///
		9  "Other" ///
		10 "Blank / Invalid" ///
		11 "Not eligible to vote"
	label value voted voted

	*** codes based on "voted last national election"
		replace voted = 0 if vote == 2
		replace voted = 11 if vote == 3


	*** code party families based on the individual variables with party choice  (ESS has a different variable per country X election year)
	* party family assignment is based on ParlGov (http://www.parlgov.org/explore/)

	* Belgium
	replace voted = 1 if prtvtbe == 7 | prtvtbe == 16 | prtvtcbe == 6 | prtvtcbe == 14 | prtvtdbe == 6 | prtvtdbe == 14
	replace voted = 2 if prtvtbe == 3 | prtvtbe == 14 | prtvtabe == 5 | prtvtabe == 13 | prtvtbbe == 5 | prtvtbbe == 13 | prtvtcbe == 5 | prtvtcbe == 13 | prtvtdbe == 5 | prtvtdbe == 13 
	replace voted = 3 if prtvtbe == 1 | prtvtbe == 11 | prtvtabe == 1 | prtvtabe == 10 | prtvtbbe == 1 | prtvtbbe == 10 | prtvtcbe == 1 | prtvtcbe == 10 | prtvtdbe == 1 | prtvtdbe == 10
	replace voted = 4 if prtvtbe == 5 | prtvtbe == 9 | prtvtbe == 13 | prtvtabe == 6 | prtvtabe == 8 | prtvtabe == 12 | prtvtbbe == 4 | prtvtbbe == 8 | prtvtbbe == 12 | prtvtcbe == 4 | prtvtcbe == 8 | prtvtcbe == 12 | prtvtdbe == 4 | prtvtdbe == 8 | prtvtdbe == 12 | prtvtdbe == 16
	replace voted = 5 if prtvtbe == 2 | prtvtbe == 12 | prtvtabe == 2 | prtvtabe == 3 | prtvtabe == 9 | prtvtbbe == 2 | prtvtbbe == 9 | prtvtcbe == 2 | prtvtcbe == 3 | prtvtcbe == 9 | prtvtcbe == 15 | prtvtdbe == 2 | prtvtdbe == 3 | prtvtdbe == 9 | prtvtdbe == 15
	replace voted = 6 if prtvtbe == 6 | prtvtbe == 8 | prtvtbe == 15 | prtvtabe == 7 | prtvtabe == 11 | prtvtbbe == 7 | prtvtbbe == 11 | prtvtcbe == 7 | prtvtcbe == 11 | prtvtdbe == 7 | prtvtdbe == 11
	replace voted = 9 if prtvtbe == 17 | prtvtabe == 14 | prtvtbbe == 14 | prtvtcbe == 16
	replace voted = 10 if prtvtabe == 15 | prtvtabe == 16 | prtvtbbe == 15 | prtvtbbe == 16 | prtvtcbe == 17 | prtvtcbe == 18
		*check
		fre prtvtbe						
		tab prtvtbe voted
		fre prtvtabe
		tab prtvtabe voted
		fre prtvtbbe
		tab prtvtbbe voted
		fre prtvtcbe
		tab prtvtcbe voted
		// new variable coded: prtvtdbe
		fre prtvtdbe
		tab prtvtdbe voted
		
		
	* Switzerland
	replace voted = 1 if prtvtbch == 7 | prtvtach == 9 | prtvtch == 9 | prtvtcch == 7 | prtvtdch == 11 | prtvtdch == 14 | prtvtech == 11 | prtvtech == 14
	replace voted = 2 if prtvtch == 3 | prtvtch == 6 | prtvtach == 3 | prtvtbch == 3 | prtvtcch == 3 | prtvtdch == 2 | prtvtech == 2
	replace voted = 3 if prtvtch == 10 | prtvtch == 14 | prtvtach == 10 | prtvtach == 14 | prtvtbch == 8 | prtvtbch == 9 | prtvtcch == 8 | prtvtcch == 9 | prtvtdch == 5 | prtvtdch == 6 | prtvtech == 5 | prtvtech == 6 | prtvtech == 15
	replace voted = 4 if prtvtch == 1 | prtvtch == 5 | prtvtach == 1 | prtvtach == 5 | prtvtbch == 1 | prtvtbch == 5 | prtvtcch == 1 | prtvtcch == 5 | prtvtdch == 3 | prtvtdch == 16 | prtvtech == 3
	replace voted = 5 if prtvtch == 2 | prtvtch == 7 | prtvtch == 8 | prtvtch == 12 | prtvtach == 2 | prtvtach == 7 | prtvtach == 8 | prtvtach == 12 | prtvtbch == 2 | prtvtbch == 6 | prtvtbch == 11 | prtvtbch == 12 | prtvtcch == 2 | prtvtcch == 6 | prtvtcch == 11 | prtvtcch == 12 | prtvtdch == 4 | prtvtdch == 7 | prtvtdch == 8 | prtvtdch == 9 | prtvtdch == 13 | prtvtech == 4 | prtvtech == 7 | prtvtech == 8 | prtvtech == 9 | prtvtech == 13
	replace voted = 6 if prtvtch == 4 | prtvtch == 11 | prtvtch == 13 | prtvtch == 15 | prtvtach == 4 | prtvtach == 11 | prtvtach == 13 | prtvtach == 15 | prtvtbch == 4 | prtvtbch == 10 | prtvtbch == 13 | prtvtcch == 4 | prtvtcch == 10 | prtvtcch == 13 | prtvtdch == 1 | prtvtdch == 10 | prtvtdch == 12 | prtvtdch == 15 | prtvtdch == 17 | prtvtech == 1 | prtvtech == 10 | prtvtech == 12
	replace voted = 9 if prtvtch == 16 | prtvtach == 16 | prtvtbch == 14 | prtvtcch == 20 | prtvtech == 18
	replace voted = 10 if prtvtbch == 15 | prtvtbch == 16 | prtvtcch == 18 | prtvtcch == 19 | prtvtdch == 19 | prtvtdch == 20 | prtvtech == 19 | prtvtech == 20
		*check
		fre prtvtch
		tab prtvtch voted
		fre prtvtach
		tab prtvtach voted
		fre prtvtbch
		tab prtvtbch voted
		fre prtvtcch
		tab prtvtcch voted
		fre prtvtdch
		tab prtvtdch voted
		fre prtvtech
		tab prtvtech voted
		// new: prtvtfch & prtvtgch
		fre prtvtfch
		
		replace voted = 1 if prtvtfch==11
		replace voted = 2 if prtvtfch==2
		replace voted = 3 if prtvtfch==5 | prtvtfch==6
		replace voted = 4 if prtvtfch==3
		replace voted = 5 if prtvtfch==4 | prtvtfch==7 | prtvtfch==8 | prtvtfch==9
		replace voted = 6 if prtvtfch==10 | prtvtfch==1
		replace voted = 9 if prtvtfch==16 | prtvtfch==18
		replace voted = 10 if prtvtfch==19 | prtvtfch==55
		
		tab prtvtfch voted
		
		fre prtvtgch
		
		replace voted = 2 if prtvtgch==2
		replace voted = 3 if prtvtgch==5 | prtvtgch==6 | prtvtgch==13
		replace voted = 4 if prtvtgch==3
		replace voted = 5 if prtvtgch==4 | prtvtgch==7 | prtvtgch==8 | prtvtgch==9
		replace voted = 6 if prtvtgch==10 | prtvtgch==1
		replace voted = 9 if prtvtgch==15
		replace voted = 10 if prtvtgch==16
		
		tab prtvtgch voted

		
	* Germany
	replace voted = 1 if prtvde2 == 5 | prtvade2 == 5 | prtvbde2 == 5 | prtvcde2 == 5 | prtvdde2 == 5 | prtvede2 == 3
	replace voted = 2 if prtvde2 == 1 | prtvade2 == 1 | prtvbde2 == 1 | prtvcde2 == 1 | prtvdde2 == 1 | prtvede2 == 2
	replace voted = 3 if prtvde2 == 3 | prtvade2 == 3 | prtvbde2 == 3 | prtvcde2 == 3 | prtvdde2 == 3 | prtvede2 == 4
	replace voted = 4 if prtvde2 == 4 | prtvade2 == 4 | prtvbde2 == 4 | prtvcde2 == 4 | prtvdde2 == 4 | prtvdde2 == 8 | prtvede2 == 5 | prtvede2 == 7
	replace voted = 5 if prtvde2 == 2 | prtvade2 == 2 | prtvbde2 == 2 | prtvcde2 == 2 | prtvdde2 == 2 | prtvede2 == 1
	replace voted = 6 if prtvde2 == 6 | prtvade2 == 6 | prtvade2 == 7 | prtvbde2 == 6 | prtvbde2 == 7 | prtvcde2 == 6 | prtvcde2 == 7 | prtvdde2 == 6 | prtvdde2 == 7 | prtvede2 == 6 | prtvede2 == 8
	replace voted = 9 if prtvde2 == 7 | prtvade2 == 8 | prtvbde2 == 8 | prtvcde2 == 8 | prtvdde2 == 9 | prtvede2 == 9
		*check
		fre prtvde2
		tab prtvde2 voted
		fre prtvade2
		tab prtvade2 voted
		fre prtvbde2
		tab prtvbde2 voted
		fre prtvcde2
		tab prtvcde2 voted
		fre prtvdde2
		tab prtvdde2 voted
		fre prtvede2
		tab prtvede2 voted
							
		// new: -
		
	* Norway
	replace voted = 1 if prtvtno == 1 | prtvtno == 2 | prtvtano == 1 | prtvtano == 2 | prtvtbno == 1 | prtvtbno == 2 
	replace voted = 2 if prtvtno == 3 | prtvtano == 3 | prtvtbno == 3
	replace voted = 3 if prtvtbno == 10
	replace voted = 4 if prtvtno == 4 | prtvtano == 4 | prtvtbno == 4
	replace voted = 5 if prtvtno == 5 | prtvtno == 7 | prtvtno == 9 | prtvtano == 5 | prtvtano == 7 | prtvtano == 9 | prtvtbno == 5 | prtvtbno == 7
	replace voted = 6 if prtvtno == 8 | prtvtano == 8 | prtvtbno == 8
	replace voted = 7 if prtvtno == 6 | prtvtano == 6 | prtvtbno == 6 | prtvtbno == 9
	replace voted = 9 if prtvtno == 10 | prtvtano == 10 | prtvtbno == 11
		*check
		fre prtvtno
		tab prtvtno voted
		fre prtvtano
		tab prtvtano voted						
		fre prtvtbno
		tab prtvtbno voted						
								
		// new: -								
		
		
	* United Kingdom
	replace voted = 1 if prtvtgb == 13 | prtvtagb == 13 | prtvtbgb == 11
	replace voted = 2 if prtvtgb == 2 | prtvtgb == 4 | prtvtgb == 14 | prtvtagb == 2 | prtvtagb == 4 | prtvtagb == 14 | prtvtbgb == 2 | prtvtbgb == 4 | prtvtbgb == 12
	replace voted = 3 if prtvtgb == 6 | prtvtagb == 6 | prtvtbgb == 6
	replace voted = 4 if prtvtgb == 3 | prtvtgb == 15 | prtvtagb == 3 | prtvtagb == 15| prtvtbgb == 3  | prtvtbgb == 13
	replace voted = 5 if prtvtgb == 1 | prtvtgb == 11 | prtvtgb == 12 | prtvtgb == 17 | prtvtagb == 1 | prtvtagb == 11 | prtvtagb == 12 | prtvtbgb == 1 | prtvtbgb == 9 | prtvtbgb == 10
	replace voted = 6 if prtvtagb == 7 | prtvtagb == 8 | prtvtbgb == 7
	replace voted = 8 if prtvtgb == 5 | prtvtagb == 5 | prtvtbgb == 5
	replace voted = 9 if prtvtgb == 7 | prtvtgb == 18 | prtvtgb == 22 | prtvtagb == 22 | prtvtbgb == 8 | prtvtbgb==14 | prtvtbgb==16 | prtvtbgb == 18
		*check
		fre prtvtgb
		tab prtvtgb voted
		fre prtvtagb
		tab prtvtagb voted
		fre prtvtbgb
		tab prtvtbgb voted
		
		// new: prtvtcgb
	fre prtvtcgb
				
		replace voted = 1 if prtvtcgb==11
		replace voted = 2 if prtvtcgb==2 | prtvtcgb==4 | prtvtcgb==12
		replace voted = 3 if prtvtcgb==6 | prtvtcgb==15
		replace voted = 4 if prtvtcgb==3 | prtvtcgb==13
		replace voted = 5 if prtvtcgb==1 | prtvtcgb==9 | prtvtcgb==10
		replace voted = 6 if prtvtcgb==7
		replace voted = 8 if prtvtcgb==5
		replace voted = 9 if prtvtcgb==16 | prtvtcgb==19
	
	tab prtvtcgb voted						
		
		
	* Sweden
	replace voted = 1 if prtvtse == 7 | prtvtase == 7 | prtvtbse == 7
	replace voted = 2 if prtvtse == 6 | prtvtase == 6 | prtvtbse == 6
	replace voted = 3 if prtvtse == 4 | prtvtase == 4 |  prtvtbse == 4
	replace voted = 4 if prtvtse == 2 | prtvtase == 2 | prtvtbse == 2
	replace voted = 5 if prtvtse == 3 | prtvtse == 5 | prtvtase == 3 | prtvtase == 5 | prtvtase == 9 | prtvtbse == 3 | prtvtbse == 5
	replace voted = 6 if prtvtase == 10 | prtvtbse == 10
	replace voted = 7 if prtvtse == 1 | prtvtase == 1 | prtvtbse == 1
	replace voted = 8 if prtvtase == 8 | prtvtbse == 8 | prtvtbse == 9
	replace voted = 9 if prtvtse == 8 | prtvtase == 11 | prtvtbse == 11
		*check
		fre prtvtse
		tab prtvtse voted
		fre prtvtase
		tab prtvtase voted
		fre prtvtbse
		tab prtvtbse voted
		
		// new: 
		fre prtvtcse
	
		replace voted = 1 if prtvtcse==7 
		replace voted = 2 if prtvtcse==6
		replace voted = 3 if prtvtcse==4
		replace voted = 4 if prtvtcse==2
		replace voted = 5 if prtvtcse==3 | prtvtcse==5
		replace voted = 6 if prtvtcse==9
		replace voted = 7 if prtvtcse==1
		replace voted = 8 if prtvtcse==8
		replace voted = 9 if prtvtcse==10
		
		tab prtvtcse voted
		
	
	*France
	replace voted = 1 if prtvtfr == 4 | prtvtfr == 5 | prtvtfr == 6 | prtvtfr == 9 | prtvtafr == 4 | prtvtafr == 5 | prtvtafr == 6 | prtvtafr == 9 | prtvtbfr == 3 | prtvtbfr == 4 | prtvtbfr == 7 | prtvtbfr == 14 | prtvtcfr == 4 | prtvtcfr == 5 | prtvtcfr == 6
	replace voted = 2 if prtvtfr == 10 | prtvtafr == 10 | prtvtbfr == 8 | prtvtbfr == 9 | prtvtcfr == 7 | prtvtcfr == 9
	replace voted = 3 if prtvtfr == 14 | prtvtfr == 15 | prtvtafr == 14 | prtvtafr == 15 | prtvtbfr == 12 | prtvtbfr == 13 | prtvtcfr == 12 | prtvtcfr == 13
	replace voted = 4 if prtvtbfr == 6 | prtvtcfr == 1
	replace voted = 5 if prtvtfr == 2 | prtvtfr == 8 | prtvtfr == 11 | prtvtfr == 12 | prtvtfr == 13 | prtvtafr == 2 | prtvtafr == 8 | prtvtafr == 11 | prtvtafr == 12 | prtvtafr == 13 | prtvtfr == 1 | prtvtafr == 1 | prtvtbfr == 1 | prtvtbfr == 5 | prtvtbfr == 10 | prtvtbfr == 11 | prtvtcfr == 3 | prtvtcfr == 8 | prtvtcfr == 10 | prtvtcfr == 11
	replace voted = 6 if prtvtfr == 3 | prtvtfr == 7 | prtvtafr == 3 | prtvtafr == 7 | prtvtbfr == 2 | prtvtbfr == 15 | prtvtcfr == 2
	replace voted = 9 if prtvtfr == 16 | prtvtafr == 16 | prtvtbfr == 16 | prtvtcfr == 14 
	replace voted = 10 if prtvtafr == 17 | prtvtbfr == 17 | prtvtbfr == 18 | prtvtcfr == 15 | prtvtcfr == 16
	
		*check
		fre prtvtfr
		tab prtvtfr voted
		fre prtvtafr
		tab prtvtafr voted
		fre prtvtbfr
		tab prtvtbfr voted
		fre prtvtcfr
		tab prtvtcfr voted
		// new: prtvtdfr
		fre prtvtdfr

		replace voted = 1 if prtvtdfr==1 | prtvtdfr==3 | prtvtdfr==4  
		replace voted = 2 if prtvtdfr==5
		replace voted = 3 if prtvtdfr==6
		replace voted = 4 if prtvtdfr==7
		replace voted = 5 if prtvtdfr==8 | prtvtdfr==9 | prtvtdfr==10
		replace voted = 6 if prtvtdfr==11
		replace voted = 9 if prtvtdfr==2 | prtvtdfr==12

		tab prtvtdfr voted
		

	* Netherlands
	replace voted = 1 if prtvtnl == 7 | prtvtanl == 7 | prtvtbnl == 7 | prtvtcnl == 7 | prtvtdnl == 5 | prtvtenl == 5 | prtvtfnl == 4
	replace voted = 2 if prtvtnl == 2 | prtvtanl == 2 | prtvtbnl == 2 | prtvtcnl == 2 | prtvtdnl == 2 | prtvtenl == 2 | prtvtfnl == 2
	replace voted = 3 if prtvtnl == 6 | prtvtanl == 6 | prtvtbnl == 6 | prtvtcnl == 6 | prtvtdnl == 7 | prtvtenl == 7 | prtvtfnl == 8
	replace voted = 4 if prtvtnl == 3 | prtvtnl == 5 | prtvtanl == 3 | prtvtanl == 5 | prtvtbnl == 3 | prtvtbnl == 5 | prtvtcnl == 3 | prtvtcnl == 5 | prtvtdnl == 1 | prtvtdnl == 6 | prtvtdnl == 11 | prtvtenl == 1 | prtvtenl == 6 | prtvtenl == 11 | prtvtenl == 12 | prtvtfnl == 1 | prtvtfnl == 6 | prtvtfnl == 11
	replace voted = 5 if prtvtnl == 1 | prtvtnl == 8 | prtvtnl == 10 | prtvtanl == 1 | prtvtanl == 8 | prtvtanl == 10 | prtvtbnl == 1 | prtvtbnl == 8 | prtvtbnl == 10 | prtvtcnl == 1 | prtvtcnl == 8 | prtvtcnl == 10 | prtvtdnl == 4 | prtvtdnl == 8 | prtvtdnl == 9 | prtvtenl == 4 | prtvtenl == 8 | prtvtenl == 9 | prtvtfnl == 5 | prtvtfnl == 7 | prtvtfnl == 9
	replace voted = 6 if prtvtnl == 4 | prtvtnl == 9 | prtvtanl == 4 | prtvtanl == 9 | prtvtbnl == 4 | prtvtbnl == 9 | prtvtcnl == 4 | prtvtcnl == 9 | prtvtcnl == 11 | prtvtdnl == 3 | prtvtenl == 3 | prtvtfnl == 3
	replace voted = 8 if prtvtanl == 11 | prtvtcnl == 11 | prtvtdnl == 10 | prtvtenl == 10 | prtvtfnl == 10
	replace voted = 9 if prtvtnl == 11 | prtvtanl == 12 | prtvtbnl == 11 | prtvtcnl == 13 | prtvtenl == 13 | prtvtdnl == 12 | prtvtenl == 13 | prtvtfnl == 16
	replace voted = 10 if prtvtanl == 13 | prtvtbnl == 12 | prtvtcnl == 14 | prtvtdnl == 13 | prtvtenl == 14 | prtvtfnl == 17
		*check
		fre prtvtnl
		tab prtvtnl voted
		fre prtvtanl
		tab prtvtanl voted
		fre prtvtbnl
		tab prtvtbnl voted
		fre prtvtcnl
		tab prtvtcnl voted
		fre prtvtdnl
		tab prtvtdnl voted
		fre prtvtenl
		tab prtvtenl voted
		fre prtvtfnl
		tab prtvtfnl voted

		// new: prtvtgnl
		fre prtvtgnl
		
		replace voted = 1 if prtvtgnl==4
		replace voted = 2 if prtvtgnl==2
		replace voted = 3 if prtvtgnl==8
		replace voted = 4 if prtvtgnl==1 | prtvtgnl==6 | prtvtgnl==11 | prtvtgnl==12 
		replace voted = 5 if prtvtgnl==5 | prtvtgnl==7 | prtvtgnl==9 
		replace voted = 6 if prtvtgnl==3 | prtvtgnl==13
		replace voted = 8 if prtvtgnl==10
		replace voted = 9 if prtvtgnl==14 | prtvtgnl==16
		replace voted = 10 if prtvtgnl==17

		tab prtvtgnl voted
	
	
	* Ireland
	replace voted = 1 if prtvtie == 6 | prtvtaie == 6 | prtvtaie == 7 | prtvtaie == 8 | prtvtaie == 9
	replace voted = 2 if prtvtie == 3 | prtvtaie == 5
	replace voted = 3 if prtvtie == 5 | prtvtaie == 3
	replace voted = 4 if prtvtie == 4
	replace voted = 5 if prtvtie == 1 | prtvtie == 2 | prtvtaie == 1 | prtvtaie == 2
	replace voted = 9 if prtvtie == 8 | prtvtaie == 10
		*check
		fre prtvtie
		tab prtvtie voted
		fre prtvtaie
		tab prtvtaie voted
		
		// new: prtvtbie prtvtcie
	fre prtvtbie
	
		replace voted = 1 if prtvtbie==1 | prtvtbie==7 | prtvtbie==9
		replace voted = 2 if prtvtbie==6 | prtvtbie==8
		replace voted = 3 if prtvtbie==4
		replace voted = 5 if prtvtbie==2 | prtvtbie==3
		replace voted = 9 if prtvtbie==5 | prtvtbie==10
	
	tab prtvtbie voted 
		
	fre prtvtcie
		
		replace voted = 1 if prtvtcie==1 | prtvtcie==7 | prtvtcie==9
		replace voted = 2 if prtvtcie==6 | prtvtcie==8
		replace voted = 3 if prtvtcie==4
		replace voted = 5 if prtvtcie==2 | prtvtcie==3
		replace voted = 9 if prtvtcie==5 | prtvtcie==10
		
	tab prtvtcie voted 		
								
		
	* Spain
	replace voted = 1 if prtvtes == 3 | prtvtaes == 3 | prtvtbes == 3 | prtvtces == 4 | prtvtces == 5 | prtvtces == 11
	replace voted = 2 if prtvtes == 2 | prtvtes == 11 | prtvtaes == 2 | prtvtaes == 11 | prtvtbes == 2 | prtvtces == 2
	replace voted = 3 if prtvtes == 6 | prtvtaes == 6
	replace voted = 4 if prtvtbes == 10 | prtvtces == 6
	replace voted = 5 if prtvtes == 1 | prtvtes == 4 | prtvtes == 7 | prtvtaes == 1 | prtvtaes == 4 | prtvtaes == 7 | prtvtbes == 1 | prtvtbes == 4 | prtvtbes == 6 | prtvtces == 1 | prtvtces == 3 | prtvtces == 7 | prtvtces == 12
	replace voted = 8 if prtvtes == 5 | prtvtes == 8 | prtvtes == 9 | prtvtes == 10 | prtvtes == 12 | prtvtaes == 5 | prtvtaes == 8 | prtvtaes == 9 | prtvtaes == 10 | prtvtaes == 12 | prtvtaes == 13 | prtvtbes == 7 | prtvtbes == 8 | prtvtbes == 9 | prtvtces == 8 | prtvtces == 9 | prtvtces == 10
	replace voted = 9 if prtvtes == 68 | prtvtaes == 74 | prtvtaes == 75 | prtvtaes == 76 | prtvtbes == 74 | prtvtbes == 75 | prtvtbes == 76 | prtvtces == 14 | prtvtces == 15 | prtvtces == 16
	replace voted = 10 if prtvtaes==75 | prtvtaes==76 | prtvtbes==75 | prtvtbes==76 | prtvtces==15 | prtvtces==16
	
		*check
		fre prtvtes
		tab prtvtes voted
		fre prtvtaes
		tab prtvtaes voted
		fre prtvtbes
		tab prtvtbes voted
		fre prtvtces
		tab prtvtces voted
		
		// new: prtvtdes & prtvtees
		fre prtvtdes
		
		replace voted = 1 if prtvtdes==3 | prtvtdes==7 | prtvtdes==8 | prtvtdes==12
		replace voted = 2 if prtvtdes==2
		replace voted = 4 if prtvtdes==5
		replace voted = 5 if prtvtdes==1 | prtvtdes==11
		replace voted = 8 if prtvtdes==10 | prtvtdes==14 | prtvtdes==15 | prtvtdes==18 | prtvtdes==50 
		replace voted = 9 if prtvtdes==50
		replace voted = 10 if prtvtdes==51 | prtvtdes==52						
		
		tab prtvtdes voted
		
		
		fre prtvtees

		replace voted = 1 if prtvtees==3 | prtvtees==7 | prtvtees==9 | prtvtees==19
		replace voted = 2 if prtvtees==2
		replace voted = 4 if prtvtees==5
		replace voted = 5 if prtvtees==1 | prtvtees==11 | prtvtees==13 | prtvtees==17
		replace voted = 6 if prtvtees==16
		replace voted = 8 if prtvtees==10 | prtvtees==12 | prtvtees==14 | prtvtees==15 | prtvtees==18
		replace voted = 9 if prtvtees==8 | prtvtees==20 | prtvtees==53
		replace voted = 10 if prtvtees==54 | prtvtees==55
		
		tab prtvtees voted
	
	
	* Finland
	replace voted = 1 if prtvtfi == 7 | prtvtfi == 10 | prtvtfi == 11 | prtvtfi == 12 | prtvtafi == 9 | prtvtafi == 10 | prtvtafi == 11 | prtvtbfi == 15 | prtvtbfi == 16 | prtvtbfi == 17 | prtvtbfi == 18 | prtvtcfi == 12 | prtvtcfi == 15 | prtvtcfi == 16
	replace voted = 2 if prtvtfi == 9 | prtvtafi == 8 | prtvtbfi == 14 | prtvtbfi == 11 | prtvtbfi == 15 | prtvtcfi == 13 | prtvtcfi == 17
	replace voted = 3 if prtvtfi == 8 | prtvtafi == 7 | prtvtbfi == 13 | prtvtcfi==12
	replace voted = 4 if prtvtfi == 2 | prtvtfi == 3 |  prtvtbfi == 2 | prtvtbfi == 3 | prtvtcfi == 2
	replace voted = 5 if prtvtfi == 1 | prtvtfi == 6 | prtvtafi == 1 | prtvtafi == 2 | prtvtafi == 3 | prtvtafi == 6 | prtvtbfi == 1 | prtvtbfi == 6 | prtvtcfi == 1 | prtvtcfi==5
	replace voted = 6 if prtvtfi == 5 | prtvtafi == 5 | prtvtbfi == 5 | prtvtbfi == 8 | prtvtcfi == 4
	replace voted = 7 if prtvtfi == 4 | prtvtafi == 4 | prtvtbfi == 4 | prtvtcfi == 3 
	replace voted = 8 if prtvtcfi == 8 | prtvtcfi == 10					
	replace voted = 9 if prtvtfi == 13 | prtvtfi == 14 | prtvtafi == 12 | prtvtbfi == 9 |  prtvtbfi == 19 | prtvtcfi==6 | prtvtcfi == 7 | prtvtcfi == 11 | prtvtcfi == 18 
		*check
		fre prtvtfi
		tab prtvtfi voted
		fre prtvtafi
		tab prtvtafi voted
		fre prtvtbfi
		tab prtvtbfi voted								
		fre prtvtcfi
		tab prtvtcfi voted

		
		// new: prtvtdfi
		fre prtvtdfi
		
		replace voted = 1 if prtvtdfi==12 | prtvtdfi==13
		replace voted = 2 if prtvtdfi==11 | prtvtdfi==15
		replace voted = 3 if prtvtdfi==10
		replace voted = 4 if prtvtdfi==2
		replace voted = 5 if prtvtdfi==1 | prtvtdfi==5
		replace voted = 6 if prtvtdfi==4
		replace voted = 7 if prtvtdfi==3
		replace voted = 8 if prtvtdfi==7 | prtvtdfi==8
		replace voted = 9 if prtvtdfi==6 | prtvtdfi==9 | prtvtdfi==16
		
		tab prtvtdfi voted

		
	* Portugal
	replace voted = 1 if prtvtpt == 1 | prtvtpt == 5 | prtvtpt == 6 | prtvtpt == 8 | prtvtapt == 1 | prtvtapt == 3 | prtvtapt == 4 | prtvtapt == 9 | prtvtbpt == 1 | prtvtbpt == 3 | prtvtbpt == 4 | prtvtbpt == 9
	replace voted = 2 if prtvtpt == 4 | prtvtpt == 10 | prtvtapt == 6 | prtvtapt == 11 | prtvtbpt == 6 | prtvtbpt == 11
	replace voted = 3 if prtvtpt == 3
	replace voted = 4 if prtvtpt == 11 | prtvtapt == 10 | prtvtbpt == 10
	replace voted = 5 if prtvtpt == 2 | prtvtpt == 9 | prtvtapt == 2 | prtvtapt == 7 | prtvtbpt == 2 | prtvtbpt == 7
	replace voted = 6 if prtvtpt == 7 | prtvtapt == 8 | prtvtbpt == 8
	replace voted = 8 if prtvtapt == 5 | prtvtbpt == 5
	replace voted = 9 if prtvtpt == 12 | prtvtbpt == 13
	replace voted = 10 if prtvtpt == 13 | prtvtapt == 12 | prtvtbpt == 12 
		*check
		fre prtvtpt
		tab prtvtpt voted
		fre prtvtapt
		tab prtvtapt voted
		fre prtvtbpt
		tab prtvtbpt voted						
		// new: prtvtcpt
	fre prtvtcpt
	
		replace voted = 1 if prtvtcpt==2 | prtvtcpt==3 | prtvtcpt==8 
		replace voted = 2 if prtvtcpt==5 | prtvtcpt==13
		replace voted = 3 if prtvtcpt==9 | prtvtcpt==15
		replace voted = 4 if prtvtcpt==16
		replace voted = 5 if prtvtcpt==7 | prtvtcpt==10 | prtvtcpt==12
		replace voted = 9 if prtvtcpt==11 | prtvtcpt==14 | prtvtcpt==18
		replace voted = 10 if prtvtcpt==17

	tab prtvtcpt voted 
	
	
****** save processed data
	save "ESS_processed.dta", replace
 

 
**# Bookmark #3
********************************************************************************
*************************** Descriptive results ********************************
********************************************************************************
	clear
	use "ESS_processed.dta"

***** Look at some descriptive statitics	
	fre cohort
	
	sum leftright redistribution immigration homosexuals environment

	bysort cohort: sum leftright 
	bysort cohort: sum redistribution_std
	bysort cohort: sum homosexuals_std
	bysort cohort: sum environment_std
	bysort cohort: sum immigration_std 


***** Figure 1. Issue attitudes and left-right positions across cohorts 

	* graph settings
	set scheme plotplainblind
	global jitter "2"

	* redistribution
	bysort cohort: pwcorr leftright redistribution

	twoway (scatter leftright redistribution if cohort==0, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright redistribution if cohort==0, lcolor(red)) ///
		   , title("interwar cohort, r=0.20") ///
		   ylabel(0 (1) 10, nolabels  nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 4, nolabels nogrid) xscale(range(-0.5 4.5)) ///
		   legend(off) name(redistribution_sg, replace) nodraw

	twoway (scatter leftright redistribution if cohort==1, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright redistribution if cohort==1, lcolor(red)) ///
		   , title("baby boomers, r=0.24") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 4, nolabels nogrid) xscale(range(-0.5 4.5)) ///
		   legend(off) name(redistribution_boom, replace) nodraw
		   
	twoway (scatter leftright redistribution if cohort==2, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright redistribution if cohort==2, lcolor(red)) ///
		   , title("generation X, r=0.25") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 4, nolabels nogrid) xscale(range(-0.5 4.5)) ///
		   legend(off) name(redistribution_X, replace) nodraw

	twoway (scatter leftright redistribution if cohort==3, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright redistribution if cohort==3, lcolor(red)) ///
		   , title("millennials, r=0.23") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 4, nolabels nogrid) xscale(range(-0.5 4.5)) ///
		   legend(off) name(redistribution_mill, replace) nodraw
		   
	graph combine redistribution_sg redistribution_boom redistribution_X redistribution_mill, row(1) imargin(zero) xsize(12) iscale(*1.5) ///
		l1title(left-right position) b1title("government should reduce differences in income levels", size(medlarge)) name(redistribution, replace) nodraw	


	* homosexuals
	bysort cohort: pwcorr leftright homosexuals

	twoway (scatter leftright homosexuals if cohort==0, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright homosexuals if cohort==0, lcolor(red)) ///
		   , title("interwar cohort, r=0.11") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 4, nolabels nogrid) xscale(range(-0.5 4.5)) ///
		   legend(off) name(homosexuals_sg, replace) nodraw

	twoway (scatter leftright homosexuals if cohort==1, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright homosexuals if cohort==1, lcolor(red)) ///
		   , title("baby boomers, r=0.13") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 4, nolabels nogrid) xscale(range(-0.5 4.5)) ///
		   legend(off) name(homosexuals_boom, replace) nodraw
		   
	twoway (scatter leftright homosexuals if cohort==2, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright homosexuals if cohort==2, lcolor(red)) ///
		   , title("generation X, r=0.13") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 4, nolabels nogrid) xscale(range(-0.5 4.5)) ///
		   legend(off) name(homosexuals_X, replace) nodraw

	twoway (scatter leftright homosexuals if cohort==3, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright homosexuals if cohort==3, lcolor(red)) ///
		   , title("millennials, r=0.11") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 4, nolabels nogrid) xscale(range(-0.5 4.5)) ///
		   legend(off) name(homosexuals_mill, replace) nodraw
		   
	graph combine homosexuals_sg homosexuals_boom homosexuals_X homosexuals_mill, row(1) imargin(zero) xsize(12) iscale(*1.5) ///
		l1title(left-right position) b1title("gays and lesbians free to live life as they wish", size(medlarge)) name(homosexuals, replace) nodraw	   


	* environment
	bysort cohort: pwcorr leftright environment

	twoway (scatter leftright environment if cohort==0, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright environment if cohort==0, lcolor(red)) ///
		   , title("interwar cohort, r=0.02") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 5, nolabels nogrid) xscale(range(-0.5 5.5)) ///
		   legend(off) name(environment_sg, replace) nodraw

	twoway (scatter leftright environment if cohort==1, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright environment if cohort==1, lcolor(red)) ///
		   , title("baby boomers, r=0.07") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 5, nolabels nogrid) xscale(range(-0.5 5.5)) ///
		   legend(off) name(environment_boom, replace) nodraw
		   
	twoway (scatter leftright environment if cohort==2, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright environment if cohort==2, lcolor(red)) ///
		   , title("generation X, r=0.11") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 5, nolabels nogrid) xscale(range(-0.5 5.5)) ///
		   legend(off) name(environment_X, replace) nodraw

	twoway (scatter leftright environment if cohort==3, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright environment if cohort==3, lcolor(red)) ///
		   , title("millennials, r=0.12") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 5, nolabels nogrid) xscale(range(-0.5 5.5)) ///
		   legend(off) name(environment_mill, replace) nodraw
		   
	graph combine environment_sg environment_boom environment_X environment_mill, row(1) imargin(zero) xsize(12) iscale(*1.5) ///
		l1title(left-right position) b1title("important to care for nature and environment", size(medlarge)) name(environment, replace) nodraw	   
	   

	* immigration
	bysort cohort: pwcorr leftright immigration

	twoway (scatter leftright immigration if cohort==0, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright immigration if cohort==0, lcolor(red)) ///
		   , title("interwar cohort, r=0.10") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 3, nolabels nogrid) xscale(range(-0.5 3.5)) ///
		   legend(off) name(immigration_sg, replace) nodraw

	twoway (scatter leftright immigration if cohort==1, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright immigration if cohort==1, lcolor(red)) ///
		   , title("baby boomers, r=0.17") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 3, nolabels nogrid) xscale(range(-0.5 3.5)) ///
		   legend(off) name(immigration_boom, replace) nodraw
		   
	twoway (scatter leftright immigration if cohort==2, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright immigration if cohort==2, lcolor(red)) ///
		   , title("generation X, r=0.18") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 3, nolabels nogrid) xscale(range(-0.5 3.5)) ///
		   legend(off) name(immigration_X, replace) nodraw

	twoway (scatter leftright immigration if cohort==3, jitter($jitter) msymbol(p) msize(vtiny) mcolor(black%12)) ///
		   (lfit leftright immigration if cohort==3, lcolor(red)) ///
		   , title("millennials, r=0.23") ///
		   ylabel(0 (1) 10, nolabels nogrid) yscale(range(-0.5 10.5)) ///
		   xtitle(" ", size(zero)) xlabel(0 (1) 3, nolabels nogrid) xscale(range(-0.5 3.5)) ///
		   legend(off) name(immigration_mill, replace) nodraw
		   
	graph combine immigration_sg immigration_boom immigration_X immigration_mill, row(1) imargin(zero) xsize(12) iscale(*1.5) ///
		l1title(left-right position) b1title("allow many immigrants from poorer countries outside Europe", size(medlarge)) name(immigration, replace) nodraw	   
	   
	* combine graphs
	graph combine redistribution homosexuals environment immigration, row(4) ysize(8) iscale(*0.75) imargin(small) name(Figure1, replace)
		graph export "Figure1.tif", width(1500) replace

		
***** Appendix A: Descriptive results
	set scheme plottig

*** Figure A1:  Don't know responses on left-right identification across countries, cohorts, and time
	encode cntry, generate(n_country)
	recode n_country (9=1 "Netherlands") (3=2 "Germany") (2=3 "Switzerland") (1=4 "Belgium") ///
			(6=5 "France") (4=6 "Spain") (11=7 "Portugal") (8=8 "Ireland") (7=9 "United Kingdom") ///
			(12=10 "Sweden") (10=11 "Norway") (5=12 "Finland"), gen(num_country)
	
		* all respondents
		preserve
			collapse (mean) lrscale_dontknow, by(year num_country)		
			twoway (line lrscale_dontknow year, sort by(num_country, cols(3) note(" ") title(all respondents) imargin(tiny)) ///
					xlabel(2002 "2002" 2010 "2010" 2018 "2018", angle(045)) xtick(2002 (2) 2018) ///
					, xtitle(ESS year) ytitle("share of don't know responses") scheme(plottig)),  name(all, replace) nodraw
		restore

		* by cohort
		preserve		
			collapse (mean) lrscale_dontknow, by(year num_country cohort)		
			twoway (line lrscale_dontknow year if cohort==0, sort by(num_country, cols(3) note(" ") title(by cohorts) imargin(tiny))) ///
				   (line lrscale_dontknow year if cohort==1, sort by(num_country)) ///
				   (line lrscale_dontknow year if cohort==2, sort by(num_country)) ///
				   (line lrscale_dontknow year if cohort==3, sort by(num_country) ///
				   xlabel(2002 "2002" 2010 "2010" 2018 "2018", angle(045)) xtick(2002 (2) 2018) ///
				   , legend(order(1 "interwar cohort" 2 "baby boomers" 3 "generation X" 4 "millennials") ///
				  row(1) pos(0)) xtitle(ESS year) ytitle("share of don't know responses") scheme(plottig)),  name(cohort, replace) nodraw
		restore

		graph combine all cohort, col(1) imargin(tiny) ysize(8) iscale(*1.15) name(FigureA1, replace)
			graph export "FigureA1.tif", width(1500) replace
			graph export "FigureA1.pdf", replace
			
			
*** Figure A2:  Mean and standard deviations of issue items by cohort
	preserve
		collapse (mean) mean_lr=leftright mean_redis=redistribution_std mean_homo=homosexuals_std mean_envi=environment_std mean_immi=immigration_std ///
				(sd) sd_lr=leftright sd_redis=redistribution_std sd_homo=homosexuals_std sd_envi=environment_std sd_immi=immigration_std  ///
				, by(cohort)
		serrbar mean_lr sd_lr cohort, xlabel(0 "interwar" 1 "boomer" 2 "gen. X" 3 "millennials") ylabel(0 (1) 10) title(left-right position) ytitle(" ") name(gr1, replace) nodraw
		serrbar mean_redis sd_redis cohort, xlabel(0 "interwar" 1 "boomer" 2 "gen. X" 3 "millennials") ylabel(0 (0.1) 1) title(redistribution) ytitle(" ") name(gr2, replace) nodraw
		serrbar mean_homo sd_homo cohort, xlabel(0 "interwar" 1 "boomer" 2 "gen. X" 3 "millennials") ylabel(0 (0.1) 1) title(homosexuals) ytitle(" ") name(gr3, replace) nodraw
		serrbar mean_envi sd_envi cohort, xlabel(0 "interwar" 1 "boomer" 2 "gen. X" 3 "millennials") ylabel(0 (0.1) 1) title(environment) ytitle(" ") name(gr4, replace) nodraw
		serrbar mean_immi sd_immi cohort, xlabel(0 "interwar" 1 "boomer" 2 "gen. X" 3 "millennials") ylabel(0 (0.1) 1) title(immigration) ytitle(" ") name(gr5, replace) nodraw

		graph combine gr2 gr3 gr4 gr5 gr1, row(3) ysize(8) name(FigureA2, replace)
			graph export "FigureA2.tif", width(1500) replace
			graph export "FigureA2.pdf", replace
	restore

	
*** Table A1: Cross-tabulation of cohorts and age groups in Western European countries
	tab cohort age_group


*** Table A2: Cross-tabulation of cohorts and education groups in Western European countries
	tab cohort education, row nofreq
	
	
	
**# Bookmark #4
********************************************************************************
*************************** Main pooled regression analysis ********************
********************************************************************************

***** Model 1: Baseline model - issue interactions with cohort, education, ESS round
	mixed leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			gndr ib2.age_group ///
			i.cntry_id || cntry_wave_id:
	
		eststo m1
	
	
		*** Figure 2. Effects of issue attitudes on left-right positions across generational cohorts from baseline model 
		* effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME1_coh
			
			estimates restore AME1_coh
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(12) mlabgap(*0.3) mlabsize(vsmall) ///
			level(95 85) swapnames xline(0) ///
			legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
			rows(4) ring(0) pos(3) size(small) rowgap(0pt)) xsize(10) scheme(plottig) ///
			scale(*1.5) ///
			xlabel(0.0 "0.0" 0.5 "0.5" 1.0 "1.0" 1.5 "1.5" 2.0 "2.0") ///
			name(Figure2, replace) 		
		
		graph combine Figure2, xsize(7) name(Figure2, replace) 		
			graph export "Figure2.tif", width(1500) replace
			graph export "Figure2.pdf", replace			
			
			
***** Model 2: Extended model - plus issue interactions with age groups
	mixed leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround  c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///			
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			gndr ///
			i.cntry_id || cntry_wave_id:

		eststo m2
		
		
		*** Figure 3. Conditional effects of issue attitudes on left-right positions from model with age X issue interactions included
		
		* effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME2_coh

			estimates restore AME2_coh
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(3) mlabgap(*6) mlabsize(tiny) ///
			level(95 85) swapnames xline(0) ///
			legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
			rows(4) ring(0) pos(3) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			xlabel(0.0 "0.0" 0.5 "0.5" 1.0 "1.0" 1.5 "1.5" 2.0 "2.0") ///
			title("effects conditional on cohort") ///
			name(cond2, replace) 
						
				* test: effect of the environment among interwar cohort vs. millennials
					estimates restore m2	
				margins, dydx(environment_std) at(cohort=(0 3)) post
				test _b[1._at] = _b[2._at]
			
		*** effects conditional on age group
			estimates restore m2	
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(age_group=(2 1 0)) post
			eststo AME2_age
			
			estimates restore AME2_age	
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(3) mlabgap(*5) mlabsize(tiny) ///
			level(95 85) swapnames xline(0) ///
			legend(order(2 "60 and older" 5 "36 to 59" 8 "up to 35") ///			
			rows(4) ring(0) pos(3) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			xlabel(0.0 "0.0" 0.5 "0.5" 1.0 "1.0" 1.5 "1.5" 2.0 "2.0") ///
			title("effects conditional on age") name(cond2_age, replace) 

		*** effects conditional on ESS wave
			estimates restore m2		
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
			eststo AME2_round			
			
			estimates restore AME2_round	
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(3) mlabgap(*4.9) mlabsize(tiny) ///
			level(95 85) swapnames xline(0) ///
			legend(order(2 "2002" 5 "2004" 8 "2006" 11 "2008" 14 "2010" 17 "2012" 20 "2014" 23 "2016" 26 "2018") ///			
			cols(1) ring(0) pos(3) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			xlabel(0.0 "0.0" 0.5 "0.5" 1.0 "1.0" 1.5 "1.5" 2.0 "2.0") ///
			title("effects conditional on ESS wave", size(medsmall)) scale(*0.88) name(cond2_wave, replace) 		
				
		*** Figure 3: Plot with effects by cohort, age and wave	
			graph combine cond2 cond2_age, imargin(vsmall) iscale(*1.2) xsize(10) row(2) xcommon name(gr1, replace)	
			graph combine gr1 cond2_wave, imargin(vsmall) iscale(*1.95) xsize(8) row(1) xcommon	name(Figure3, replace) 		
				graph export "Figure3.tif", width(1500) replace
				graph export "Figure3.pdf", replace								

				
				
**# Bookmark #5				
********************************************************************************
********** Appendix B: Additional results for main pooled analysis *************
********************************************************************************
				
	*** Table B1: Full regression table for pooled analysis
	esttab m1 m2 using "TableB1.rtf", b(a2) se(a2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
			varwidth(30) nogaps compress replace label scalars(r2) ///
			keep(redistribution_std homosexuals_std immigration_std environment_std 1.cohort* 2.cohort* 3.cohort* ///
			*essround* ///
			*age_group* ///
			1.education* 2.education* 3.education* 4.education* ///
			gndr)	

			
	*** Figure B1: Conditional effects of issue attitudes on left-right positions by education level from model 2 in Table B1
		estimates restore m2	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(education=(1 2 3 4)) post
		eststo AME2_educ
				
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
		, msymbol(+) mlabel format(%9.2f) mlabposition(12) mlabgap(*0.3) mlabsize(vsmall) ///
		level(95 85) swapnames xline(0) ///
		legend(order(2 "less than lower secondary" 5 "lower secondary" 8 "upper secondary" 11 "tertiary") ///			
		rows(4) ring(0) pos(3) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
		scale(*1.5) ///
		name(FigureB1, replace) 
		
	graph combine FigureB1, xsize(7) name(FigureB1, replace) 		
		graph export "FigureB1.tif", width(1500) replace
		graph export "FigureB1.pdf", replace				


		
**# Bookmark #6							
********************************************************************************
****** Appendix C: Robustness checks for the pooled regression analysis ********
********************************************************************************
		
		
	****** Figure C1: Effects of issue attitudes on left-right positions across generational cohorts with factor for immigration attitudes (instead of single item) 
		
	* Model 1: Baseline model
		mixed leftright ///
				c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
				c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
				c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
				c.immigration_fact_std##i.cohort c.immigration_fact_std##i.essround c.immigration_fact_std##ib3.education  ///
				gndr ib2.age_group ///
				i.cntry_id || cntry_wave_id:
		
		eststo m1
		
			* effects conditional on cohort
			margins, dydx(redistribution_std homosexuals_std environment_std immigration_fact_std) at(cohort=(0 1 2 3)) post
				eststo AME1_imfact
						
			coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
				, msymbol(+) level(95 85) swapnames xline(0) ///
				legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
				rows(4) ring(0) pos(11) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
				title("baseline model") name(cond1_imfact, replace) 				
				
	* Model 2: Extended model
		mixed leftright ///
				c.redistribution_std##i.cohort c.redistribution_std##i.essround  c.redistribution_std##ib3.education ///
				c.redistribution_std##ib2.age_group ///
				c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
				c.homosexuals_std##ib2.age_group ///
				c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
				c.environment_std##ib2.age_group ///			
				c.immigration_fact_std##i.cohort c.immigration_std##i.essround c.immigration_fact_std##ib3.education  ///
				c.immigration_fact_std##ib2.age_group ///
				gndr ///
				i.cntry_id || cntry_wave_id:

			eststo m2_imfact
			
			* effects conditional on cohort
			margins, dydx(redistribution_std homosexuals_std environment_std immigration_fact_std) at(cohort=(0 1 2 3)) post
				eststo AME2_imfact
					
			coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
				, msymbol(+) level(95 85) swapnames xline(0) ///
				legend(off) xsize(10) scheme(plottig) ///
				title("with additional age X issue interaction") name(cond2_imfact, replace) 
				
		graph combine cond1_imfact cond2_imfact, iscale(*1.9) xsize(8) xcommon name(FigureC1, replace)
			graph export "FigureC1.tif", width(1500) replace
			graph export "FigureC1.pdf", replace					
		
		
	
	****** Figure C2: Effects of issue attitudes on left-right positions across generational cohorts without issue-education-interactions

	* Model 1: Baseline model
		mixed leftright ///
				c.redistribution_std##i.cohort c.redistribution_std##i.essround  ///
				c.homosexuals_std##i.cohort c.homosexuals_std##i.essround ///
				c.environment_std##i.cohort c.environment_std##i.essround ///
				c.immigration_std##i.cohort c.immigration_std##i.essround ///
				gndr ib2.age_group ib3.education ///
				i.cntry_id || cntry_wave_id:
					
				eststo m1_woeduc
					
		* effects conditional on cohort 
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
				eststo AME1_woeduc

				estimates restore AME1_woeduc
				
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
				, msymbol(+) level(95 85) swapnames xline(0) ///
				legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
				rows(4) ring(0) pos(11) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
				title("baseline model") name(cond1_woeduc, replace) 	

		* Model 2: Extended model
		mixed leftright ///
				c.redistribution_std##i.cohort c.redistribution_std##i.essround ///
				c.redistribution_std##ib2.age_group ///
				c.homosexuals_std##i.cohort c.homosexuals_std##i.essround ///
				c.homosexuals_std##ib2.age_group ///
				c.environment_std##i.cohort c.environment_std##i.essround ///
				c.environment_std##ib2.age_group ///			
				c.immigration_std##i.cohort c.immigration_std##i.essround ///
				c.immigration_std##ib2.age_group ///
				gndr ///
				i.cntry_id || cntry_wave_id:

			eststo m2_woeduc
	
		* effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME2_woeduc
				
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title("with additional age X issue interaction") name(cond2_woeduc, replace) 
			
		graph combine cond1_woeduc cond2_woeduc, iscale(*1.9) xsize(8) xcommon name(FigureC2, replace)	
			graph export "FigureC2.tif", width(1500) replace
			graph export "FigureC2.pdf", replace			
				
				
	
	****** Figure C3: Effects of issue attitudes on left-right positions across generational cohorts with alternative cohort scheme (10-year intervals)

	* Model 1: Baseline model
		mixed leftright ///
				c.redistribution_std##i.cohort_alt c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
				c.homosexuals_std##i.cohort_alt c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
				c.environment_std##i.cohort_alt c.environment_std##i.essround c.environment_std##ib3.education ///
				c.immigration_std##i.cohort_alt c.immigration_std##i.essround c.immigration_std##ib3.education  ///
				gndr ib2.age_group ///
				i.cntry_id || cntry_wave_id:
		
		eststo m1_altcoh1
		
		* effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort_alt=(0 1 2 3 4 5 6)) post
			eststo AME1_altcoh1
					
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) (, keep(*:6._at)) (, keep(*:7._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "until 1939" 5 "1940s" 8 "1950s" 11 "1960s" 14 "1970s" 17 "1980s" 20 "1990 onwards" ) ///			
			cols(1) ring(0) pos(11) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			title("baseline model") name(cond1_altcoh1, replace) scale(*1.8)		
		
	* Model 2: Extended model
		mixed leftright ///
				c.redistribution_std##i.cohort_alt c.redistribution_std##i.essround  c.redistribution_std##ib3.education ///
				c.redistribution_std##ib2.age_group ///
				c.homosexuals_std##i.cohort_alt c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
				c.homosexuals_std##ib2.age_group ///
				c.environment_std##i.cohort_alt c.environment_std##i.essround c.environment_std##ib3.education ///
				c.environment_std##ib2.age_group ///			
				c.immigration_std##i.cohort_alt c.immigration_std##i.essround c.immigration_std##ib3.education  ///
				c.immigration_std##ib2.age_group ///
				gndr ///
				i.cntry_id || cntry_wave_id:

		eststo m2_altcoh1

		* effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort_alt=(0 1 2 3 4 5 6)) post
			eststo AME2_altcoh1
					
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) (, keep(*:6._at)) (, keep(*:7._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "until 1939" 5 "1940s" 8 "1950s" 11 "1960s" 14 "1970s" 17 "1980s" 20 "1990 onwards" ) ///			
			cols(1) ring(0) pos(11) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			title("with additional age X issue interaction") name(cond2_altcoh1, replace) scale(*1.8)		
		
	graph combine cond1_altcoh1 cond2_altcoh1, row(2) iscale(*0.65) ysize(6) xcommon name(FigureC3, replace)	
		graph export "FigureC3.tif", width(1500) replace			
		graph export "FigureC3.pdf", replace

			

	****** Figure C4: Effects of issue attitudes on left-right positions across generational cohorts with alternative cohort scheme (5-year intervals)
				
	* Model 1: Baseline model
		mixed leftright ///
				c.redistribution_std##i.cohort_alt2 c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
				c.homosexuals_std##i.cohort_alt2 c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
				c.environment_std##i.cohort_alt2 c.environment_std##i.essround c.environment_std##ib3.education ///
				c.immigration_std##i.cohort_alt2 c.immigration_std##i.essround c.immigration_std##ib3.education  ///
				gndr ib2.age_group ///
				i.cntry_id || cntry_wave_id:
		
		eststo m1_altcoh2
		
		* effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort_alt=(0 (1) 15)) post
			eststo AME1_altcoh2
					
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) (, keep(*:6._at)) (, keep(*:7._at)) ///
			(, keep(*:8._at)) (, keep(*:9._at)) (, keep(*:10._at)) (, keep(*:11._at)) (, keep(*:12._at)) (, keep(*:13._at)) (, keep(*:14._at)) ///
			(, keep(*:15._at)) (, keep(*:16._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "until 1924" 5 "1925-1929" 8 "1930-1934" 11 "1935-1939" 14 "1940-1944" 17 "1945-1949" 20 "1950-1954" 23 "1955-1959" ///
			26 "1960-1964" 29 "1965-1969" 32 "1970-1974" 35 "1975-1979" 38 "1980-1984" 41 "1985-1989" 44 "1990-1994" 47 "1995 onwards") ///			
			cols(1) ring(0) pos(3) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			xlabel(0 1 2 3) ///
			title("baseline model") name(cond1_altcoh2, replace) scale(*1.8)				
		
	* Model 2: Extended model
		mixed leftright ///
				c.redistribution_std##i.cohort_alt2 c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
				c.redistribution_std##ib2.age_group ///
				c.homosexuals_std##i.cohort_alt2 c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
				c.homosexuals_std##ib2.age_group ///
				c.environment_std##i.cohort_alt2 c.environment_std##i.essround c.environment_std##ib3.education ///
				c.environment_std##ib2.age_group ///			
				c.immigration_std##i.cohort_alt2 c.immigration_std##i.essround c.immigration_std##ib3.education  ///
				c.immigration_std##ib2.age_group ///
				gndr ///
				i.cntry_id || cntry_wave_id:

		eststo m2_altcoh2

		* effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort_alt=(0 (1) 15)) post
			eststo AME2_altcoh2
					
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) (, keep(*:6._at)) (, keep(*:7._at)) ///
			(, keep(*:8._at)) (, keep(*:9._at)) (, keep(*:10._at)) (, keep(*:11._at)) (, keep(*:12._at)) (, keep(*:13._at)) (, keep(*:14._at)) ///
			(, keep(*:15._at)) (, keep(*:16._at)) (, keep(*:17._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "until 1924" 5 "1925-1929" 8 "1930-1934" 11 "1935-1939" 14 "1940-1944" 17 "1945-1949" 20 "1950-1954" 23 "1955-1959" ///
			26 "1960-1964" 29 "1965-1969" 32 "1970-1974" 35 "1975-1979" 38 "1980-1984" 41 "1985-1989" 44 "1990-1994" 47 "1995 onwards") ///			
			cols(1) ring(0) pos(3) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			title("with additional age X issue interaction") name(cond2_altcoh2, replace) scale(*1.8)		

		graph combine cond1_altcoh2 cond2_altcoh2, row(2) iscale(*0.65) ysize(6) xcommon name(FigureC4, replace)	
			graph export "FigureC4.tif", width(1500) replace
			graph export "FigureC4.pdf", replace

			
			
	****** Figure C5: Effects of issue attitudes on left-right positions across generational cohorts with alternative age groups
			
	* recode age group
	recode age(0/29=0 "-29") (30/65=1 "30-65") (66/130=3 "66+"), gen(age_group2)

	tab age_group2 cohort	
		
	* Model 2: Extended model - version A of alternative age groups
		mixed leftright ///
				c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
				c.redistribution_std##ib2.age_group2 ///
				c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
				c.homosexuals_std##ib2.age_group2 ///
				c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
				c.environment_std##ib2.age_group2 ///			
				c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
				c.immigration_std##ib2.age_group2 ///
				gndr ///
				i.cntry_id || cntry_wave_id:

		* effects conditional on cohort 
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME1_coh

			estimates restore AME1_coh	
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
			rows(4) ring(0) pos(11) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			title("With age groups: -29; 30-65; 66+") name(cond1, replace) 				
					
	* recode age group
	recode age(0/24=0 "-24") (25/60=1 "25-60") (61/130=3 "61+"), gen(age_group3)

	tab age_group3 cohort	
		
	* Model 2: Extended model - version B of alternative age groups
		mixed leftright ///
				c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
				c.redistribution_std##ib2.age_group3 ///
				c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
				c.homosexuals_std##ib2.age_group3 ///
				c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
				c.environment_std##ib2.age_group3 ///			
				c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
				c.immigration_std##ib2.age_group3 ///
				gndr ///
				i.cntry_id || cntry_wave_id:

		* effects conditional on cohort 
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME2_coh
				
			estimates restore AME2_coh	
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
			rows(4) ring(0) pos(11) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			title("With age groups: -24; 25-60; 61+") name(cond2, replace) 
			
		graph combine cond1 cond2, iscale(*1.9) xsize(8) xcommon name(FigureC5, replace)				
			graph export "FigureC5.tif", width(1500) replace
			graph export "FigureC5.pdf", replace

			

	****** Figure C6:  Effects of issue attitudes on left-right positions across generational cohorts, separate models per issue item
	*** Model 1
	* Redistribution only: model 1
	mixed leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			gndr ib2.age_group ///
			i.cntry_id || cntry_wave_id:
	
		* marginal effect
		margins, dydx(redistribution_std) at(cohort=(0 1 2 3)) post
			eststo redistribution
	
	* Homosexuality only: model 1
	mixed leftright ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			gndr ib2.age_group ///
			i.cntry_id || cntry_wave_id:		
	
		* marginal effect
		margins, dydx(homosexuals_std) at(cohort=(0 1 2 3)) post
			eststo homosexuals
			
	* Environment only: model 1
	mixed leftright ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			gndr ib2.age_group ///
			i.cntry_id || cntry_wave_id:		
	
		* marginal effect
		margins, dydx(environment_std) at(cohort=(0 1 2 3)) post
			eststo environment
			
	* Immigration only: model 1
	mixed leftright ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			gndr ib2.age_group ///
			i.cntry_id || cntry_wave_id:		
	
		* marginal effect
		margins, dydx(immigration_std) at(cohort=(0 1 2 3)) post
			eststo immigration
			
		coefplot (redistribution \ homosexuals \ environment \ immigration)  ///
			, aseq msymbol(+) level(95 85)  xline(0) ///
			xlabel(0 (0.5) 2) ///	
			coeflabels(1._at="interwar" 2._at="boomers" 3._at="gen. X" 4._at="millenn.") ///
			 xsize(10) scheme(plottig) ///
			title("baseline model") name(cond1, replace) 	

	*** Model 2
	* Redistribution only: model 2
	mixed leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education c.redistribution_std##ib2.age_group ///
			gndr ///
			i.cntry_id || cntry_wave_id:
	
		* marginal effect
		margins, dydx(redistribution_std) at(cohort=(0 1 2 3)) post
			eststo redistribution
	
	* Homosexuality only: model 2
	mixed leftright ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education c.homosexuals_std##ib2.age_group ///
			gndr ///
			i.cntry_id || cntry_wave_id:		
	
		* marginal effect
		margins, dydx(homosexuals_std) at(cohort=(0 1 2 3)) post
			eststo homosexuals
			
	* Environment only: model 2
	mixed leftright ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education c.environment_std##ib2.age_group ///
			gndr ///
			i.cntry_id || cntry_wave_id:		
	
		* marginal effect
		margins, dydx(environment_std) at(cohort=(0 1 2 3)) post
			eststo environment
			
	* Immigration only: model 2
	mixed leftright ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education c.immigration_std##ib2.age_group ///
			gndr  ///
			i.cntry_id || cntry_wave_id:		
	
		* marginal effect
		margins, dydx(immigration_std) at(cohort=(0 1 2 3)) post
			eststo immigration
			
		coefplot (redistribution \ homosexuals \ environment \ immigration)  ///
			, aseq msymbol(+) level(95 85)  xline(0) ///
			xlabel(0 (0.5) 2) ///	
			coeflabels(1._at="interwar" 2._at="boomers" 3._at="gen. X" 4._at="millenn.") ///
			 xsize(10) scheme(plottig) ///
			title("plus ageXissue") name(cond2, replace) 	

	graph combine cond1 cond2, imargin(small) iscale(*1.9) xsize(8) xcommon name(FigureC6, replace)				
			graph export "FigureC6.tif", width(1500) replace
			graph export "FigureC6.pdf", replace

	
	
	****** Figure C7:  Effects of issue attitudes on left-right positions across generational cohorts, excluding voters of Green and radical-right parties		
		
	* Model 1: Baseline model	
		mixed leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			gndr ib2.age_group ///
			i.cntry_id || cntry_wave_id: if voted!=3 & voted!=6 & voted<.
	
		eststo m1
		tab cntry year if e(sample)
	
		*** effects conditional on cohort 
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME1_coh_woGReenRR
					
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
			rows(4) ring(0) pos(11) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			title("baseline model") name(cond1_woGReenRR, replace) 			
			
	* Model 2: Extended model
	mixed leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround  c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///			
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			gndr ///
			i.cntry_id || cntry_wave_id: if voted!=3 & voted!=6 & voted<.

		eststo m2
		
		*** effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME2_coh_woGReenRR
				
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title("with additional age X issue interaction") name(cond2_woGReenRR, replace) 
			
	graph combine cond1_woGReenRR cond2_woGReenRR, iscale(*1.9) xsize(8) xcommon name(FigureC7, replace)				
			graph export "FigureC7.tif", width(1500) replace
			graph export "FigureC7.pdf", replace
		
		
		
	****** Figure C8: Effects of issue attitudes on left-right positions across generational cohorts, including only voters of social-democratic and conservative as well as Christian-democratic parties	

	* Model 1: Baseline model 		
		mixed leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			gndr ib2.age_group ///
			i.cntry_id || cntry_wave_id: if voted==2 | voted==5 
	
	eststo m1
	tab cntry year if e(sample)
	
		*** effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME1_coh_wSDCons
					
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
			rows(4) ring(0) pos(11) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			title("baseline model") name(cond1_wSDCons, replace) 			
			
	* Model 2: Extended model
	mixed leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround  c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///			
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			gndr ///
			i.cntry_id || cntry_wave_id: if voted==2 | voted==5 
			
		eststo m2
		
		*** effects conditional on cohort
		margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
			eststo AME2_coh_wSDCons
				
		coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title("with additional age X issue interaction") name(cond2_wSDCons, replace) 
			
		graph combine cond1_wSDCons cond2_wSDCons, iscale(*1.9) xsize(8) xcommon name(FigureC8, replace)				
			graph export "FigureC8.tif", width(1500) replace
			graph export "FigureC8.pdf", replace
		
		
		
**# Bookmark #7						
********************************************************************************
************* Regressions by country (baseline specification ) *****************
********************************************************************************
	
	* BE: Belgium
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="BE"
	eststo BE
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo BE_marg
	
	estimates restore BE_marg
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3.7) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0)  ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Belgium, size(medium)) name(BE, replace) nodraw
			
	estimates restore BE
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+)  level(95 85) swapnames xline(0) ///
			legend(order(2 "2002" 5 "2004" 8 "2006" 11 "2008" 14 "2010" 17 "2012" 20 "2014" 23 "2016" 26 "2018") ///			
			cols(1) ring(0) pos(3) size(vsmall) rowgap(0pt)) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Belgium, size(medium)) name(wave_BE, replace) nodraw
	
	
* DE: Germany
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="DE"
	eststo DE
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo DE_marg
	
	estimates restore DE_marg	
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0)  ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Germany, size(medium)) name(DE, replace) nodraw

	estimates restore DE
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Germany, size(medium)) name(wave_DE, replace) nodraw		

			
* NL: Netherlands
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="NL"
	eststo NL
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0)  ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Netherlands, size(medium)) name(NL, replace) nodraw		
	
	estimates restore NL
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Netherlands, size(medium)) name(wave_NL, replace) nodraw		
		

* CH: Switzerland
		reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="CH"
	eststo CH
		
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0)  ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Switzerland, size(medium)) name(CH, replace) nodraw
		
	estimates restore CH
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Switzerland, size(medium)) name(wave_CH, replace) nodraw		
		
			
* GB: Great Britain
		reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="GB"
	eststo GB
		
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post	
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title(United Kingdom, size(medium)) name(GB, replace) nodraw
		
	estimates restore GB
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(United Kingdom, size(medium)) name(wave_GB, replace) nodraw		
		
			
* IE: Ireland
		reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="IE"
	eststo IE
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post	
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Ireland, size(medium)) name(IE, replace) nodraw		
	
	estimates restore IE
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Ireland, size(medium)) name(wave_IE, replace) nodraw		
		
			
* SE: SWEDEN
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="SE"
	eststo SE
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post	
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3.5) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Sweden, size(medium)) name(SE, replace) nodraw		
	
	estimates restore SE
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Sweden, size(medium)) name(wave_SE, replace) nodraw		
		
	
* NO: Norway
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="NO"
	eststo NO
			
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post	
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Norway, size(medium)) name(NO, replace) nodraw	
	
	estimates restore NO
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Norway, size(medium)) name(wave_NO, replace) nodraw		
		
	
* FR: France
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="FR"
	eststo FR
		
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title(France, size(medium)) name(FR, replace) nodraw	
	
	estimates restore FR
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(France, size(medium)) name(wave_FR, replace) nodraw		
		
	
* PT: Portugal
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="PT"
	eststo PT
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*4.3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Portugal, size(medium)) name(PT, replace) nodraw	
	
	estimates restore PT
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Portugal, size(medium)) name(wave_PT, replace) nodraw		
		
				
* ES: Spain
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="ES"
	eststo ES
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post	
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*4.4) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			title(Spain, size(medium)) name(ES, replace) nodraw	
		
	estimates restore ES
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Spain, size(medium)) name(wave_ES, replace) nodraw		
		
	
* FI: FINLAND
		reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education ///
			gndr ib2.age_group ///
			if cntry=="FI"
	eststo FI
		
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post	
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) mlabel format(%9.2f) mlabposition(9) mlabgap(*3) mlabsize(tiny) /// 
			xlabel(-1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5", gmin gmax) ///
			level(95 85) swapnames xline(0) ///
			legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
			rows(4) ring(0) pos(5) size(vsmall) rowgap(0pt) colgap(0pt) keygap(zero)) xsize(10) scheme(plottig) ///
			title(Finland, size(medium)) name(FI, replace) nodraw	
	
	estimates restore FI
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(essround=(1 2 3 4 5 6 7 8 9)) post
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) (, keep(*:5._at)) ///
			(, keep(*:6._at)) (, keep(*:7._at)) (, keep(*:8._at)) (, keep(*:9._at))  ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Finland, size(medium)) name(wave_FI, replace) nodraw		
		
	
***** Figure 4. Effects of issue attitudes on left-right positions by cohort across countries
	graph combine NL BE DE CH FR ES PT IE GB SE NO FI, col(2) ysize(8) iscale(*1.45) imargin(tiny) name(Figure4, replace)				
			graph export "Figure4.tif", width(1500) replace
			graph export "Figure4.pdf", replace

			
			
**# Bookmark #8							
********************************************************************************
**** Appendix D: Additional results for the regression analysis by country *****
********************************************************************************			
		
		
****** Figure D1: Conditional effects of issue attitudes on left-right positions by ESS wave (baseline model, without age X issue interaction)
	graph combine wave_NL wave_BE wave_DE wave_CH wave_FR wave_ES wave_PT wave_IE wave_GB wave_SE wave_NO wave_FI, col(2) ysize(8) iscale(*1.45) imargin(tiny) name(FigureD1, replace)
			graph export "FigureD1.tif", width(1500) replace
			graph export "FigureD1.pdf", replace
	
	
***** Regressions by country with age X issue interaction
* BE: Belgium
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="BE"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo BE
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0)  ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Belgium, size(medium)) name(BE, replace) nodraw
	
	
* DE: Germany
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="DE"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo DE
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0)  ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Germany, size(medium)) name(DE, replace) nodraw

			
* NL: Netherlands
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="NL"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo NL
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0)  ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Netherlands, size(medium)) name(NL, replace) nodraw
	

* CH: Switzerland
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="CH"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo CH
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0)  ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Switzerland, size(medium)) name(CH, replace) nodraw

			
* GB: Great Britain
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="GB"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo GB
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(United Kingdom, size(medium)) name(GB, replace) nodraw

			
* IE: Ireland
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="IE"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo IE
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Ireland, size(medium)) name(IE, replace) nodraw	
		
		
* SE: SWEDEN
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="SE"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo SE
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Sweden, size(medium)) name(SE, replace) nodraw	

			
* NO: Norway
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="NO"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo NO
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Norway, size(medium)) name(NO, replace) nodraw	

			
* FR: France
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="FR"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo NO
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(France, size(medium)) name(FR, replace) nodraw	

			
* PT: Portugal
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="PT"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo PT
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Portugal, size(medium)) name(PT, replace)	nodraw
		
		
* ES: Spain
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="ES"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo ES
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(off) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Spain, size(medium)) name(ES, replace) nodraw

			
* FI: FINLAND
	reg leftright ///
			c.redistribution_std##i.cohort c.redistribution_std##i.essround c.redistribution_std##ib3.education ///
			c.redistribution_std##ib2.age_group ///
			c.homosexuals_std##i.cohort c.homosexuals_std##i.essround c.homosexuals_std##ib3.education ///
			c.homosexuals_std##ib2.age_group ///
			c.environment_std##i.cohort c.environment_std##i.essround c.environment_std##ib3.education ///
			c.environment_std##ib2.age_group ///								
			c.immigration_std##i.cohort c.immigration_std##i.essround c.immigration_std##ib3.education  ///
			c.immigration_std##ib2.age_group ///
			if cntry=="FI"
	
	margins, dydx(redistribution_std homosexuals_std environment_std immigration_std) at(cohort=(0 1 2 3)) post
	eststo FI
		
	coefplot (, keep(*:1._at)) (, keep(*:2._at)) (, keep(*:3._at)) (, keep(*:4._at)) ///
			, msymbol(+) level(95 85) swapnames xline(0) ///
			legend(order(2 "interwar cohort" 5 "baby boomers" 8 "generation X" 11 "millennials") ///			
			rows(4) ring(0) pos(5) size(vsmall) rowgap(0pt) colgap(0pt) keygap(zero)) xsize(10) scheme(plottig) ///
			xlabel(-1 (1) 5, gmin gmax) ///
			title(Finland, size(medium)) name(FI, replace)	nodraw
			
		
****** Figure D2: Conditional effects of issue attitudes on left-right positions by cohort with additional control for issue X age group interaction
	graph combine NL BE DE CH FR ES PT IE GB SE NO FI, col(2) ysize(8) iscale(*1.45) imargin(tiny)  name(FigureD2, replace)
			graph export "FigureD2.tif", width(1500) replace
			graph export "FigureD2.pdf", replace